<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">


	$(function() {
	
		$('#condidateIds').combotree({
		    url: '${ctx}/voter/tree?usertype=2',
		    multiple: true,
		    required: true,
		    panelHeight : 'auto',
		    value : $.stringToList('${t.candidate}')
		});
		
		$('#voterIds').combotree({
		    url: '${ctx}/voter/tree?usertype=3',
		    multiple: true,
		    required: true,
		    panelHeight : 'auto',
		    value : $.stringToList('${t.voter}')
		});
		
		$('#userAddForm').form({
			url : '${ctx}/voter/add',
			onSubmit : function() {
				progressLoad();
				var isValid = $(this).form('validate');
				if (!isValid) {
					progressClose();
				}
				return isValid;
			},
			success : function(result) {
				progressClose();
				result = $.parseJSON(result);
				if (result.success) {
					parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
					parent.$.modalDialog.handler.dialog('close');
				} else {
					parent.$.messager.alert('提示', result.msg, 'warning');
				}
			}
		});
		
		pubMethod.bind('usertype', 'usertype');
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="overflow: hidden;padding: 3px;">
		<form id="userAddForm" method="post">
			<c:if test="${t.id != null}">
				<input type="hidden" value="${t.id }" name="id"/>
			</c:if>
			<table class="grid">
				<tr>
					<td>投票标题</td>
					<td colspan="3">
						<input name="title" type="text" placeholder="请输入投票标题" class="easyui-textbox" 
						data-options="required:true" value="${t.title }" style="width: 400px; height: 29px;">
					</td>
				</tr>
				<tr>
					<td>投票内容</td>
					<td colspan="3">
						<textarea name="content" rows="5" cols="50" >${t.content }</textarea>
					</td>
				</tr>
				<tr>
					<td>开始时间</td>
					<td><input type="text" value="${t.starttime }" name="starttime" class="easyui-datetimebox" 
						data-options="
							required:true,
							editable:false
						"
						style="height: 29px;" 
					/></td>
					<td>结束时间</td>
					<td><input type="text" value="${t.endtime }" name="endtime" class="easyui-datetimebox" 
						data-options="
							required:true,
							editable:false
						"
						style="height: 29px;" 
					/></td>
				</tr>
				<tr>
					<td>投票类型</td>
					<td colspan="3">
						<select name="type" style="width: 140px; height: 29px;" 
						class="easyui-validatebox" data-options="required:true">
							<option value="1">一人一票</option>
							<option value="2">一人多票</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>候选人</td>
					<td colspan="3">
						<select id="condidateIds" name="candidate" style="width: 400px; height: 29px;" 
						class="easyui-validatebox" data-options="required:true">
						</select>
					</td>
				</tr>
				<tr>
					<td>投票人</td>
					<td colspan="3">
						<select id="voterIds" name="voter" style="width: 400px; height: 29px;" 
						class="easyui-validatebox" data-options="required:true">
						</select>
					</td>
					
				</tr>
			</table>
		</form>
	</div>
</div>